﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace WebApplication1
{
    public partial class Login : System.Web.UI.Page
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            LoginButton.Click += new EventHandler(LoginButton_Click);
        }

        void LoginButton_Click(object sender, EventArgs e)
        {
            if (!IsValid) return;
            var user = MentorBackEnd.DA.UserDA.Authenticate(UserName.Text, Password.Text);
            if (user == null)
                custBadPair.IsValid = false;
            else
            {
                FormsAuthentication.SetAuthCookie(user.MeMaUserID.ToString(), RememberMe.Checked);
                Response.Redirect("~/Account/Profile.aspx");
            }
        }
    }
}